package com.koron.order.patrol.controller;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.patrol.bean.po.PatrolEquipmentPo;
import com.koron.order.patrol.service.PatrolEquipmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 巡视工单-巡视点设备从表(PatrolEquipment)表控制层
 *
 * @author zhouj
 * @since 2021-10-26 15:25:51
 */
@Api(tags = "巡视工单-巡视点设备从表(PatrolEquipment)")
@RestController
@RequestMapping("/patrolEquipment/")
public class PatrolEquipmentController {

    @Autowired
    private PatrolEquipmentService patrolEquipmentService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "新增或修改巡视工单-巡视点设备从表")
    @PostMapping("insertOrUpdate")
    public Response<String> insertOrUpdate(@RequestBody PatrolEquipmentPo patrolEquipment) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolEquipmentService, "insertOrUpdate", String.class, patrolEquipment));
    }

    @ApiOperation(value = "新增巡视工单-巡视点设备从表")
    @PostMapping("insert")
    public Response<Integer> insert(@RequestBody PatrolEquipmentPo patrolEquipment) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolEquipmentService, "insert", Integer.class, patrolEquipment));
    }

    @ApiOperation(value = "批量新增巡视工单-巡视点设备从表")
    @PostMapping("insertBatch")
    public Response<Integer> insertBatch(@RequestBody List<PatrolEquipmentPo> patrolEquipmentList) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolEquipmentService, "insertBatch", Integer.class, patrolEquipmentList));
    }

    @ApiOperation(value = "根据id更新巡视工单-巡视点设备从表")
    @PutMapping("update")
    public Response<Integer> update(@RequestBody PatrolEquipmentPo patrolEquipment) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolEquipmentService, "update", Integer.class, patrolEquipment));
    }

    @ApiOperation(value = "根据id删除巡视工单-巡视点设备从表")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolEquipmentService, "deleteById", Integer.class, id));
    }

    @ApiOperation(value = "根据id查询巡视工单-巡视点设备从表")
    @GetMapping("queryById")
    public Response<PatrolEquipmentPo> queryById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolEquipmentService, "queryById", PatrolEquipmentPo.class, id));
    }

    @ApiOperation(value = "不分页查询巡视工单-巡视点设备从表列表")
    @GetMapping("queryList")
    public Response<List> queryList(PatrolEquipmentPo queryVo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolEquipmentService, "queryList", List.class, queryVo));
    }

    @ApiOperation(value = "分页查询巡视工单-巡视点设备从表列表")
    @GetMapping("queryPageList")
    public Response<PageInfo> queryPageList(PatrolEquipmentPo queryPo, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), patrolEquipmentService, "queryPageList", PageInfo.class, queryPo, pageQuery));
    }

}
